package com.car.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import com.car.util.ConnectionPool;

public class AutoHomeCarID {
	static Logger logger = Logger.getLogger(AutoHomeCarID.class.getName());
	private String hostip = "192.168.1.168";

	public List<Integer> getBrandCarIDs() {
		logger.info("从carvoice_core数据库core_brand表中开始得到brand_id");
		int count = 0;
		List<Integer> carIDs = new ArrayList<Integer>();
		Connection conn = ConnectionPool.getConnection("carvoice_core", "root", "zhouzhou100428", hostip);
		Statement st;
		ResultSet rs;
		String sql = "SELECT brand_autohomeId FROM core_brand";
		try {
			st = conn.createStatement();
			rs = st.executeQuery(sql);
			while (rs.next()) {
				int carID = rs.getInt("brand_autohomeId");
				carIDs.add(carID);
				count++;
			}
		} catch (Exception e) {
			logger.error("从carvoice_core数据库core_brand表中得到brand_id过程中出现异常");
			e.printStackTrace();
		}
		logger.info("从carvoice_core数据库core_brand表中开始得到brand_id,共得到" + count + "条数据");
		return carIDs;
	}

	public static void main(String[] args) {
		AutoHomeCarID a = new AutoHomeCarID();
		a.getBrandCarIDs();
	}
}
